import request from '@/utils/request'

// 分类管理API
export default {
  // 分页查询分类列表
  getTableDataApi(searchModel) {
    return request({
      url: '/category/selectPageData',
      method: 'post',
      params: {
        page: searchModel.currentPage,
        size: searchModel.pageSize,
        name: searchModel.name
      }
    })
  },

  // 获取所有分类
  getAllCategoriesApi() {
    return request({
      url: '/category/getAllCategories',
      method: 'get'
    })
  },

  // 新增/编辑分类
  updateAndSaveApi(category) {
    return request({
      url: '/category/updateAndSave',
      method: 'post',
      data: category
    })
  },

  // 删除分类
  delDataApi(id) {
    return request({
      url: `/category/delDataById/${id}`,
      method: 'delete'
    })
  },

  // 批量删除分类
  delDataByIdsApi(ids) {
    return request({
      url: '/category/delDataByIds',
      method: 'post',
      data: ids
    })
  }
}
